package com.sbx.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sbx.entity.dto.AppDock;
import com.sbx.mapper.AppDockMapper;
import com.sbx.service.AppDockService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;

@Service
public class AppDockServiceImpl implements AppDockService {
    @Resource
    private AppDockMapper appDockMapper;


    @Override
    public void insert(AppDock appDock) {
        appDockMapper.insert(appDock);
    }

    @Override
    public void deleteById(Integer id) {
        appDockMapper.deleteById(id);
    }

    @Override
    public Page<?> getAppDockPage(AppDock appDock, Integer pageIndex, Integer pageSize) {
        Page<AppDock> appDockPage = new Page<>(pageIndex, pageSize);
        LambdaQueryWrapper<AppDock> wrapper = new LambdaQueryWrapper<>();
        wrapper.like(!StringUtils.isEmpty(appDock.getChName()), AppDock::getChName, appDock.getChName());
        wrapper.like(!StringUtils.isEmpty(appDock.getNote()), AppDock::getNote, appDock.getNote());
        wrapper.like(!StringUtils.isEmpty(appDock.getEnName()), AppDock::getEnName, appDock.getEnName());
        wrapper.eq(!StringUtils.isEmpty(appDock.getRoleId()), AppDock::getRoleId, appDock.getRoleId());
        return appDockMapper.selectPage(appDockPage, wrapper);
    }

    @Override
    public void update(AppDock appDock) {
        appDockMapper.updateById(appDock);
    }
}
